<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>阿豪传媒</title>
    <style>
        .container {
            min-height: 100vh;
        }

        .container .nav {
            height: 100%;
            background-color: #fff;
        }

        .link-secondary {
            text-decoration: none;
        }

        .link-secondary:hover {
            color: #0d6efd !important;
        }

        .position-relative .position-absolute {
            display: none;
        }

        .card:hover .position-absolute {
            display: block;
        }
    </style>
</head>

<body>
    <!-- container 是 bootstrap的居中窄显示方案 -->
    <div class="container bg-transparent">
        <div class="row">
            <div class="col-md-2 leftmenu" id="leftmenu"></div>
            <div class="col-md-9 kc ms-3">
                <div class="row mt-3">
                    <!-- row似乎不能同时使用flex布局 -->
                    <ul class="nav nav-tabs">
                        <li class="nav-item">
                            <a class="nav-link nav-tab active" aria-current="page" href="#">我教的课程</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link nav-tab" href="#">我学的课程</a>
                        </li>
                        <li class="nav-item">
                            <select class="form-select" aria-label="select example">
                                <option selected value="-1">请选择学期</option>
                                <option value="0">2022~2023第二学期</option>
                                <option value="1">2022~2023第一学期</option>
                                <option value="2">2021~2022第二学期</option>
                                <option value="3">2021~2022第一学期</option>
                            </select>
                        </li>
                        <li class="nav-item ms-5" style="position: relative;">
                            <input type="text" class="form-control rounded-pill" placeholder="请输入课程名">
                            <i class="bi bi-search" style="position: absolute;right:1rem ;top: 0.7rem;"></i>
                        </li>
                        <li class="nav-item ms-3">
                            <a class="nav-link link-success" href="#">
                                <i class="bi bi-plus-circle-fill"></i>
                                创建文件夹
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link link-success" href="./course.html">
                                <i class="bi bi-plus-circle-fill"></i>
                                创建课程
                            </a>
                        </li>
                    </ul>
                </div>
                <div class="row" id="courses">
                    <!-- <div class="card mt-3 ms-3" style="width: 18rem;">
                        <img src="../scss/imgs/美2.jpeg" width="200px" height="200px" class="card-img-top mt-2" alt="主演">
                        <div class="card-body">
                            <h5 class="card-title">最新作品 </h5>
                            <h6 class="mt-1 text-muted">阿豪传媒工作室</h6>
                            <h6 class="mt-1 text-muted">2023.01~2023.04</h6>
                            <h6 class="mt-1 text-muted">主演 阿豪</h6>
                            <h6 class="mt-1 text-muted d-flex justify-content-between">
                                <div>精品</div>
                                <div>浏览量9999999+<i class="bi bi-chevron-right"></i></div>
                            </h6>
                        </div>
                    </div>
                    <div class="card mt-3 ms-3" style="width: 18rem;">
                        <img src="../scss/imgs/美1.jpeg" width="200px" height="200px" class="card-img-top mt-2" alt="主演">
                        <div class="card-body">
                            <h5 class="card-title">最新作品 </h5>
                            <h6 class="mt-1 text-muted">阿豪传媒工作室</h6>
                            <h6 class="mt-1 text-muted">2023.01~2023.04</h6>
                            <h6 class="mt-1 text-muted">主演 阿豪</h6>
                            <h6 class="mt-1 text-muted d-flex justify-content-between">
                                <div>精品</div>
                                <div>浏览量9999999+<i class="bi bi-chevron-right"></i></div>
                            </h6>
                        </div>
                    </div>
                    <div class="card mt-3 ms-3" style="width: 18rem;">
                        <img src="../scss/imgs/美3.jpg" width="200px" height="200px" class="card-img-top mt-2" alt="主演">
                        <div class="card-body">
                            <h5 class="card-title">最新作品 </h5>
                            <h6 class="mt-1 text-muted">阿豪传媒工作室</h6>
                            <h6 class="mt-1 text-muted">2023.01~2023.04</h6>
                            <h6 class="mt-1 text-muted">主演 阿豪</h6>
                            <h6 class="mt-1 text-muted d-flex justify-content-between">
                                <div>精品</div>
                                <div>浏览量9999999+<i class="bi bi-chevron-right"></i></div>
                            </h6>
                        </div>
                    </div>
                    <div class="card mt-3 ms-3" style="width: 18rem;">
                        <img src="../scss/imgs/美4.jpg" width="200px" height="200px" class="card-img-top mt-2" alt="主演">
                        <div class="card-body">
                            <h5 class="card-title">最新作品 </h5>
                            <h6 class="mt-1 text-muted">阿豪传媒工作室</h6>
                            <h6 class="mt-1 text-muted">2023.01~2023.04</h6>
                            <h6 class="mt-1 text-muted">主演 阿豪</h6>
                            <h6 class="mt-1 text-muted d-flex justify-content-between">
                                <div>精品</div>
                                <div>浏览量9999999+<i class="bi bi-chevron-right"></i></div>
                            </h6>
                        </div>
                    </div>
                    <div class="card mt-3 ms-3" style="width: 18rem;">
                        <img src="../scss/imgs/美5.jpeg" width="200px" height="200px" class="card-img-top mt-2" alt="主演">
                        <div class="card-body">
                            <h5 class="card-title">最新作品 </h5>
                            <h6 class="mt-1 text-muted">阿豪传媒工作室</h6>
                            <h6 class="mt-1 text-muted">2023.01~2023.04</h6>
                            <h6 class="mt-1 text-muted">主演 阿豪</h6>
                            <h6 class="mt-1 text-muted d-flex justify-content-between">
                                <div>精品</div>
                                <div>浏览量9999999+<i class="bi bi-chevron-right"></i></div>
                            </h6>
                        </div>
                    </div>
                    <div class="card mt-3 ms-3" style="width: 18rem;">
                        <img src="../scss/imgs/美6.jpeg" width="200px" height="200px" class="card-img-top mt-2" alt="主演">
                        <div class="card-body">
                            <h5 class="card-title">最新作品 </h5>
                            <h6 class="mt-1 text-muted">阿豪传媒工作室</h6>
                            <h6 class="mt-1 text-muted">2023.01~2023.04</h6>
                            <h6 class="mt-1 text-muted">主演 阿豪</h6>
                            <h6 class="mt-1 text-muted d-flex justify-content-between">
                                <div>精品</div>
                                <div>浏览量9999999+<i class="bi bi-chevron-right"></i></div>
                            </h6>
                        </div>
                    </div> -->
                </div>
            </div>
        </div>
    </div>
    <div class=" d-grid gap-2 justify-content-md-end fixed-bottom mb-3 ">
        <a href="#" class="btn btn-outline-primary rounded-pill mt-3 ">
            <i class="bi bi-megaphone-fill"></i>
            更新公告
        </a>
        <a href="#" class="btn btn-outline-primary rounded-pill mt-3 ">
            <i class="bi bi-question-circle-fill"></i>
            使用帮助
        </a>
        <a href="#" class="btn btn-outline-primary rounded-pill mt-3 ">
            <i class="bi bi-headset"></i>
            在线客服
        </a>
        <a href="#" class="btn btn-outline-primary rounded-pill mt-3 ">
            <i class="bi bi-capslock-fill"></i>
            返回顶部
        </a>
    </div>
    <script type="module" src="../js/main.js"></script>
    <script src="../js/jquery.min.js"></script>
    <script src="../js/common.js"></script>
    <script>
        $(document).ready(function () {
            //当用户点击class是nav-tab的标签给该标签（添加之前删除所有active类）添加active类
            $(".nav-tab").click(function (e) {
                //删除nav-tab所有active类
                $(".nav-tab").removeClass("active");
                //给点击的标签添加active类
                $(this).addClass("active")
            })
            $.get("https://unicloud.codecore.cn/ms/courseAll?teacher_id=645484f2819ce8deeea2a59b", {}, function (params) {
                if (params.errCode == 0) {
                    for (let i = 0; i < params.data.length; i++) {
                        const elem = params.data[i];
                        $("#courses").append($(`<div class="card mt-3 position-relative ms-3" style="width: 18rem;">
                            <div class="position-absolute top-0 end-0" style="right: 0;">
                            <button class="btn btn-info bian"data-id=${elem._id}>移动到</button>
                            <button class="btn btn-info shan"data-id="${elem._id}">退课</button>
                        </div>
                        <img src="${elem.course_url}"  alt="主演">
                        <div class="card-body">
                            <h5 class="card-title">${elem.course_name}</h5>
                            <h6 class="mt-1 text-muted">阿豪传媒工作室</h6>
                            <h6 class="mt-1 text-muted">2023.01~2023.04</h6>    
                            <h6 class="mt-1 text-muted">主演 ${elem.teacher_name}</h6>
                            <h6 class="mt-1 text-muted d-flex justify-content-between">
                                <div>${elem.grade_code} ${elem.course_department}</div>
                                <div>浏览量9999999+<i class="bi bi-chevron-right"></i></div>
                            </h6>
                        </div>
                    </div>`))
                    }
                }
            })
            $("#courses").delegate("button.shan", "click", function () {
                // $(this).data() 获取点击元素上data属性中存放的数据
                let data = $(this).data();// data数据格式是{id:"字符串"} 比较符合后端要求 可以直接传递
                $.post("http://unicloud.codecore.cn/ms/courseRemove", data, function (params) {
                    console.log(params);
                    if (params.errCode == 0) {
                        location.reload();
                    } else { alert("退课异常") }
                })
            });

            $("#courses").delegate("button.bian", "click", function () {
                let data = $(this).data();
                // 跳转到新的页面 并将要编辑的数据的ID编号带过去
                 location.href =`./edit_course.html?id=${data.id}`
            })
        })
    </script>

</body>

</html>